#ifndef HASIO_IMPL_IO_CONTEXT_HPP
#define HASIO_IMPL_IO_CONTEXT_HPP

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)

#include "../detail/executor_op.hpp"

namespace hasio {

struct io_context::initiate_post
{
    template<typename Handler>
    void operator()(Handler handler, io_context* self)
    {
        self->impl_.post_operation(new detail::executor_op<Handler>(handler));
    }
};

template <typename Service>
inline Service& use_service(io_context &ioc)
{
    return *(new Service());
}

template <>
inline detail::io_context_impl&
use_service<detail::io_context_impl>(io_context &ioc)
{
    return ioc.impl_;
}

}

#endif // HASIO_IMPL_IO_CONTEXT_HPP 